package com.test.threadTest.bf1;

import java.util.concurrent.TimeUnit;

/**
 *  volatile__JMM线程模型、主线程__子线程
 */
public class VisableDemo {

    private volatile static boolean stop=false;

    public static void main(String[] args) throws InterruptedException {

        Thread thread=new Thread(()->{
            int i=0;
            while(!stop){
                i++;
                System.out.println(i);
            }
        });
        thread.start();
        TimeUnit.SECONDS.sleep(1);
        stop=true;
    }
}
